#include "unp.h"
#include "unpifi.h"

int main(int argc, char **argv)
{
  struct ifi_info *ifi, *ifihead;
  struct sockaddr *sa;
  u_char *ptr;
  char buf[128] = {'\0'};
    
  ifihead = get_ifi_info(AF_INET,1);
  for (ifi = ifihead; ifi != NULL; ifi = ifi->ifi_next)
  {
    printf("%s ", ifi->ifi_name);
    printf("<");
    if (ifi->ifi_flags & IFF_UP)	printf("UP ");
    if (ifi->ifi_flags & IFF_BROADCAST)	printf("BCAST ");
    if (ifi->ifi_flags & IFF_MULTICAST)	printf("MCAST ");
    if (ifi->ifi_flags & IFF_LOOPBACK)	printf("LOOP ");
    printf(">\n");    
    
    printf("  MTU: %d\n",ifi->ifi_mtu);
    if (ifi->ifi_addr != NULL) 
      printf("  IP addr:%s\n",inet_ntop(AF_INET,&ifi->ifi_addr->sin_addr,buf,sizeof(sockaddr_in)));
    if (ifi->ifi_brdaddr != NULL)
      printf("  Broadcast addr:%s\n",inet_ntop(AF_INET,&ifi->ifi_brdaddr->sin_addr,buf,sizeof(sockaddr_in)));
  }

  free_ifi_info(ifihead);
  return 0;
}
